var app = getApp();
Page({
	data: {
		active:1,
		list:[],
		winHei:0,
		winWid:0
	},
	/**
	* 页面初始化加载
	*/
	onLoad:function(){
		wx.getSystemInfo({
			success: (res)=> {
				this.setData({
					winHei:res.windowHeight,
					winWid:res.windowWidth
				})
			}
		})
		this.fetch(1);
	},
	/**
	* 设置页面头部样式
	*/
	onReady(){
		// app.setTitle();
	},
	/**
	* 选项卡切换
	*/
	_toggleClick:function(evt){
		var active = evt.currentTarget.dataset.active;
		this.setData({
			active
		})
		this.fetch(active);
	},
	/**
	*数据请求
	*/
	fetch:function(type){
		var url = "orders/getOrdersList";
		var paramsData={
			type
		}

		app._post(url,paramsData,(res)=>{
			if (res.code === 1){
				var list = res.data.list;
				if (list instanceof Array){
					list.forEach((item)=>{
						item.order_info = JSON.parse(item.order_info);
						item.status = type == 1 ? '未受理' : '已受理';
					})
					this.setData({
						list
					})
				}
			}else{
				app.showError(result.msg);
			}
		})
	}
})